const useAppStore = defineStore(
    'app',
    {
        state: () => ({
            connectList: [],
            usedConnect: {},
            globalPushData: {},
            connectType: null,
        }),
        actions: {
            setConnectList(connectList) {
                this.connectList = connectList
            }, pushConnect(connect) {
                if (typeof connect === 'string') {
                    this.connectList.push(JSON.parse(connect))
                } else {
                    this.connectList.push(connect)
                }
            }, deleteConnect(connect) {
                let index = this.connectList.indexOf(connect)
                if (index !== -1) {
                    this.connectList.splice(index, 1)
                }
            }, setUsedConnect(keyName,value) {
                this.usedConnect[keyName] = value
            }, setGlobalData(keyName, value) {
                this.globalPushData[keyName] = value
            }, setConnectType(connectType) {
                this.connectType = connectType
            }, checkConnectOpen(usedConnect) {
                return !!this.usedConnect[usedConnect.id]
            }
        }
    })

export default useAppStore
